////////////////////////////////////////////////
//	File Name	:	"CGame.h"
//
//	Author Name	:	Mason Miller
//
//	Purpose	:	To contain all game related code.
////////////////////////////////////////////////

//	Cross compiler
#ifndef _CGAME_H_
#define _CGAME_H_

#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480

//	SGD singletons:
#include "Wrappers\CSGD_Direct3D.h"
#include "Wrappers\CSGD_TextureManager.h"
#include "Wrappers\CSGD_FModManager.h"
#include "Wrappers\CSGD_DirectInput.h"
#include "ObjectFactory.h"
#include "ObjectManager.h"

////////////////////////////////////////////////
#include "Game Objects\CObjectFactory.h"
#include <string>
using std::string;
//	ALWAYS INCLUDE THESE TOGETHER
////////////////////////////////////////////////

#include <vector>

#include "IGameState.h"
#include "CStopWatch.h"

class CObjectManager;
class CBase;

class CGame
{
private:
	//	Singleton members:
	CSGD_Direct3D*						m_pD3D;
	CSGD_TextureManager*				m_pTM;
	CSGD_FModManager*					m_pFM;
	CSGD_DirectInput*					m_pDI;
	ObjectManager*						m_pOM;
	ObjectFactory<string, CBase>*		m_pOF;
	CSGP_MessageSystem*					m_pMS;
	CSGP_EventSystem*					m_pES;

	
	//	Pointer to the current state:
	std::vector<IGameState*>			m_vGS;

	//	Asset ids:

	//	Screen Size
	int									m_nScreenWidth;
	int									m_nScreenHeight;

	// Volume values
	float	m_fMusicVolume;
	float	m_fSFXVolume;

	//	Game objects:

	//	Game timing:
	DWORD								m_dwTimeStamp;
	CStopWatch							m_stopWatch;
	float								m_fElapsedTime;	//	dt.	The time(in secs) between frames.
	float								m_fGameTime;	//	how long the game has been running.

	//	For FPS counting:
	//int									m_nFrameCount;		//	the current frame count.
	//int									m_nFPS;				//	frame count from previous second for display.

	//DWORD								m_dwFPSTimeStamp;	//	time stamp from previous frame.

	//	Windowed Mode
	bool								m_bIsWindowed;

	//	Constructor
	CGame(void);
	//	Destructor
	~CGame(void);
	//	Copy Constructor
	CGame(const CGame&);
	//	Assignment Operator
	CGame& operator=(const CGame&);

	//	Utility functions:
	bool Input(void);
	void Update(void);
	void Render(void);

public:
	//	Singleton Accessor
	static CGame* GetInstance(void);

	// Get the states
	std::vector<IGameState*> GetStates() { return m_vGS; }

	//	3 steps a game does during its lifetime:
	//	Initialization
	void Initialize(HWND hWnd, HINSTANCE hInstance, int nScreenWidth, int nScreenHeight, bool bIsWindowed);

	//	Execution
	//	NOTE: Returns false when game should quit.
	bool GameMain(void);

	//	Clean Up
	void Shutdown(void);

	//	Changes the game's current state
	void ChangeState(IGameState* pGameState, bool overide = false);

	// Push and pop states for vector of states
	void PushState(IGameState* state);
	void PopState();

	// Clear all states
	void ClearAllStates();

	////////////////////////////////////////////////
	//	Function	:	Accessors
	//	Purpose		:	To get the specified type.
	////////////////////////////////////////////////
	int GetScreenWidth(void)		{return m_nScreenWidth;}
	int GetScreenHeight(void)		{return m_nScreenHeight;}
	float GetElapsedTime(void)		{return m_fElapsedTime;}
	float GetGameTime(void)			{return m_fGameTime;}
	bool GetFullscreen(void)		{return m_bIsWindowed;}

	float GetMusicVolume() { return m_fMusicVolume; }
	void SetMusicVolume(float fVol) { m_fMusicVolume = fVol; }
	float GetSFXVolume() { return m_fSFXVolume; }
	void SetSFXVolume(float fVol) { m_fSFXVolume = fVol; }
	
	////////////////////////////////////////////////
	//	Function	:	Modifiers
	//	Purpose		:	To set the specified type.
	////////////////////////////////////////////////
	void SetFullscreen(bool bFullScreen)		{m_bIsWindowed = bFullScreen;}

	
};

#endif